<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$gametype = 1;
if ($curruser['enabled'] == 0)
{
    $ui->showErrorPage("帐号已被暂停使用");
    exit();
}
include_once( "class/function_3d.php" );
$ui = new UI_3D(true);
$tpl = new Template2();
$today = date("Y-m-d");
$pagecount = $conf->get("page_max_count");
$xyidArr = array(0 => "", 1 => "X 盘", 2 => "Y盘");
$g_betname_3or5Arr = array();
foreach ($g_gametype_3d as $gameid => $val)
{
    if ($gameid == 0)
    {
        $g_betname_3or5Arr[0] = array();
    }
    else
    {
        $g_betname_3or5Arr[$gameid] = judge_type($gameid, true);
    }
}
$showDate = getvar("showDate");
$showDate = $showDate == "" ? $today : $showDate;
if (!is_date($showDate))
{
    exit("error date type");
}
else if (strtotime($showDate) < strtotime("-10 day"))
{
    $ui->showErrorPage("只能查询10天之内的帐");
    exit();
}
$postTime = $conf->get("paper_post_bet");
require_once( "class_sb/RateConfig_sb.php" );
$RateConfig_sb=new RateConfig_sb(25);
$today = date("Hi") <= $postTime ? date("Y-m-d", strtotime("-1 day")) : date("Y-m-d");
foreach ($g_gametype_3d as $key => $value)
{
    $game_3d3s[$key] = $key;
}
$game_3d3s[0] = "";
$sqlArr = array();
foreach ($g_gametype_3d as $key => $val)
{
    if (!$g_init_mode_6h && $key == 0)
    {
        continue;
    }
    if (!$g_init_mode_3d && $key === $game_3d3s[$key])
    {
        continue;
    }
    if ($g_menu_enabled[$key] == 0)
    {
        continue;
    }
    $x = $showDate == $today ? "" : "x";
    if ($val['en'] == "6h")
    {
        $tempTbl = "";
        $x = "";
        $subSql = " 0 as subid ";
    }
    else
    {
        $tempTbl = "_" . $val['en'];
        $subSql = " a.subid ";
    }
    if ($conf->get("calcbet{$tempTbl}") == 1)
    {
        $ui->showErrorPage($val['ch'] . "颁奖过帐中，无法查询全部资料，请稍後再使用本功能！", true);
        exit();
    }
    else if ($conf->get("systemcheck_" . $val['en']) == 1)
    {
        $ui->showErrorPage($val['ch'] . "系统维謢中，无法查询全部资料，请稍後再使用本功能！", true);
        exit();
    }
    if ($val['en'] == "5h")
    {
        $xyid = " a.xyid ";
    }
    else
    {
        $xyid = " 0 as xyid ";
    }
    $sql = " SELECT a.numbers, b.round, a.amount, a.a1, a.b1, b.open, a.createtime, a.bettype, {$xyid}, {$subSql}, a.rate, a.rame, a.line_nums, {$key} as gametype, a.disk FROM {$x}bet{$tempTbl} a";
    $sql .= " LEFT JOIN lotto{$tempTbl} b ON (b.id = a.lotto_id)";
    $sql .= " WHERE a.user_id =" . $curruser['id'] . " AND a.rame IN(0,9) AND b.open = '{$showDate}'";
    array_push($sqlArr, $sql);
}
$sql = implode(" UNION ALL ", $sqlArr);
$sql .= " ORDER BY createtime DESC ";
$rs = getdb($sql);
$list = "";
$sum_amount = 0;
$sum_a1 = 0;
$sum_b1 = 0;
$count = 0;
if (!$rs->eof)
{
    while (!$rs->eof)
    {
        $list .= "<tr class=td2 valign=top>";
        $list .= "<td nowrap>" . date("m-d H:i", $rs->f['createtime']) . "</td>";
        $list .= "<td nowrap>" . $rs->f['round'] . "</td>";
        $list .= "<td nowrap class=\"paper" . $g_gametype_3d[$rs->f['gametype']]['en'] . "\">" . $g_gametype_3d[$rs->f['gametype']]['ch'] . "</td>";
        if ($rs->f['gametype'] == 0)
        {
            $list .= "<td nowrap>" . GetBetContent($rs->f['bettype'], $rs->f['numbers'], $rs->f['amount']) . "</td>";
        }
        else if ($rs->f['gametype'] == 20 && $rs->f['bettype'] < 9)
        {
            $xyid = "&nbsp;<font color=\"blue\">" . $xyidArr[$rs->f['xyid']] . "</font>";
            $list .= "<td nowrap>" . $xyid . "【" . $g_betname_3or5Arr[$rs->f['gametype']][$rs->f['bettype'] . "_" . $rs->f['subid']] . "】&nbsp;" . nl2br($rs->f['line_nums']) . "</td>";
        }
        else
        {
			if($rs->f['gametype']==25 || $rs->f['gametype']==26)
				$list .= "<td nowrap>【" . $g_betname_3or5Arr[$rs->f['gametype']][$rs->f['bettype']]  . "】&nbsp;" . $RateConfig_sb->getBetContent($rs->f['bettype'],$rs->f['line_nums']) . "</td>";
			else
            	$list .= "<td nowrap>【" . $g_betname_3or5Arr[$rs->f['gametype']][$rs->f['bettype'] . "_" . $rs->f['subid']] . "】&nbsp;" . nl2br($rs->f['line_nums']) . "</td>";
        }
        $list .= "<td nowrap align=right>" . $g_disk_name[$rs->f['disk']] . "</td>";
        $list .= "<td nowrap align=right>" . floatval($rs->f['rate']) . "</td>";
        $list .= "<td nowrap align=right>" . $rs->f['amount'] . "</td>";
        $list .= "<td nowrap align=right>" . $rs->f['a1'] . "</td>";
        $list .= "<td nowrap align=right>" . say_numbercolor($rs->f['b1']) . "</td>";
        $sum_amount += $rs->f['amount'];
        $sum_a1 += $rs->f['a1'];
        $sum_b1 += $rs->f['b1'];
        ++$count;
        if ($rs->f['rame'] == 1)
        {
            $list .= "<td nowrap align=center><font color=red>- 逾时 -</font></td>";
        }
        else if ($rs->f['rame'] == 2)
        {
            $list .= "<td nowrap align=center><font color=red>- 取消 -</font></td>";
        }
        else if ($rs->f['rame'] == 3)
        {
            $list .= "<td nowrap align=center><font color=red>- 异常 -</font></td>";
        }
        else if (chkBet_peace($rs->f))
        {
            $list .= "<td nowrap align=center><font color=blue>- 和局 -</font></td>";
        }
        else
        {
            $list .= "<td nowrap align=right>&nbsp;</td>";
        }
        $list .= "</tr>";
        $rs->next();
    }
}
else
{
    $list = "<tr class=\"row1\"><td colspan=\"11\" align=\"center\">没有下注资料！</td></tr>";
}
$tpl->load("main", "view_all.htm");
$tpl->set(array("count" => $count, "sum_amount" => $sum_amount, "sum_a1" => $sum_a1, "sum_b1" => say_numbercolor($sum_b1), "open" => "{$showDate}", "list" => $list, "gametypeStr" => "全部"));
$ui->header();
$tpl->show("main");
$ui->footer();
?>